import request from '@/utils/request'
import { limit } from '@/consts/consts'

const url = process.env.VUE_APP_ENV === 'production' ? `http://${window.location.host}/datak` : 'datak'

export default {

  // 9.9.1. 设备类型、品牌、型号映射列表
  brandModelList(data) {
    if (!data.limit) {
      data.limit = limit
    }
    return request({
      url: `${url}/api/v1/iot/device-type-brand-model-map/list`,
      method: 'get',
      params: data
    })
    // return request.get(`${url}/api/v1/iot/device-type-brand-model-map/list?offset=${offset}&limit=${limit}&brand_name=${brandName}&device_type=${deviceType}`)
  },
  //   9.1.2. 添加设备类型、品牌、型号映射
  brandModelAdd(data) {
    return request.post(`${url}/api/v1/iot/device-type-brand-model-map/add`, data)
  },
  //   9.1.4. 删除设备类型、品牌、型号映射
  brandModelDelete(id) {
    return request.delete(`${url}/api/v1/iot/device-type-brand-model-map/delete/${id}`)
  },

  // 9.9.5. 根据设备类型获取 品牌列表、型号列表
  brandModelListByType(type) {
    return request.get(`${url}/api/v1/iot/device-type-brand-model-map/get?device_type=${type}`)
  },
  // 9.9.6.根据设备类型、品牌获取型号表
  modelListByBrand({ deviceType, brandId }) {
    return request.get(`${url}/api/v1/iot/device-type-brand-model-map/acquire?device_type=${deviceType}&brand_id=${brandId}`)
  },

  // 9.9.7.根据设备类型获取型号表和品牌
  modelMapShow({
    limit = limit,
    offset,
    ...data
  }) {
    return request.post(`${url}/api/v1/iot/device-type-brand-model-map/show?offset=${offset}&limit=${limit}`, data)
  },

  // 9.10.1.导入烤箱EPQC品相数据
  bakerEPQCCategoryImport() {
    return `${url}/api/v1/iot/baker-epqc-category/import`
  },
  // 9.10.2.烤箱EPQC品相数据列表
  bakerEPQCCategoryList({ offset, limit, storeId }) {
    // 李峰说storeId废弃
    // return request.get(`${url}/api/v1/iot/baker-epqc-category/list?offset=${offset}&limit=${limit}&store_id=${storeId}`)
    return request.get(`${url}/api/v1/iot/baker-epqc-category/list?offset=${offset}&limit=${limit}`)
  },
  // 9.10.3.烤箱菜单列表
  bakerMenuList({ limit, offset, paramsData }) {
    if (!limit) {
      limit = limit
    }
    // 李峰说storeId废弃
    // return request.get(`${url}/api/v1/iot/baker-menu/list?offset=${offset}&limit=${limit}&store_id=${storeId}`)
    return request.post(`${url}/api/v1/iot/baker-menu/list?offset=${offset}&limit=${limit}`, paramsData)
  },
  // 9.10.4.烤箱新增菜单
  bakerMenuAdd(data) {
    return request.post(`${url}/api/v1/iot/baker-menu/add`, data)
  },
  // 9.10.5.烤箱删除菜单
  bakerMenuDelete(menuId) {
    return request.delete(`${url}/api/v1/iot/baker-menu/delete/${menuId}`)
  },
  // 9.10.6.导入烤箱菜单
  bakerMenuImport(queryData) {
    return `${url}/api/v1/iot/baker-menu/import?device_type=${queryData.device_type}&brand_name=${queryData.brand_name}&model_name=${queryData.model_name}&group_id=${queryData.group_id}`
  },
  // 9.10.7.烤箱菜单已选品相 new
  bakerMenuCategorySelected(menuId) {
    return request.get(`${url}/api/v1/iot/baker-menu/epqc-data/list?menu_id=${menuId}`)
  },
  // 9.10.8.烤箱菜单品项配置 new
  bakerMenuCategoryConfig(data) {
    return request.post(`${url}/api/v1/iot/baker-menu/epqc-data/add`, data)
  },
  // 9.10.7.导入烤箱品相数据
  bakerCategoryImport() {
    return `${url}/api/v1/iot/baker-category/import`
  },
  // 9.10.8.烤箱品相数据列表
  bakerCategoryList({ limit, offset }) {
    return request.get(`${url}/api/v1/iot/baker-category/list?offset=${offset}&limit=${limit}`)
  },
  // 9.10.9.烤箱菜单修改
  bakerMenuUpdate(data) {
    return request.put(`${url}/api/v1/iot/baker-menu/update`, data)
  },
  // 9.10.10.品相下发
  epqcCategoryIssue(data) {
    return request.post(`${url}/api/v1/iot/epqc-category/issue`, data)
  },
  // 9.10.11.品相下发状态
  epqcCategoryIssueStatus(data) {
    return request.post(`${url}/api/v1/iot/epqc-category/issue/status`, data)
  },
  // 9.11.1.导入炸锅EPQC品相数据 废弃
  firePressCategoryImport() {
    // return request.post(`${url}/api/v1/iot/frier-epqc-category/import`)
    return `${url}/api/v1/iot/frier-epqc-category/import`
  },
  // 9.11.2.炸锅EPQC品相数据列表
  firePressEPQCCategoryList({ offset, limit = limit, storeId }) {
    // 李峰说storeId废弃
    // return request.get(`${url}/api/v1/iot/frier-epqc-category/list?offset=${offset}&limit=${limit}&store_id=${storeId}`)
    return request.get(`${url}/api/v1/iot/frier-epqc-category/list?offset=${offset}&limit=${limit}`)
  },
  // 9.11.3.炸锅按键列表
  firePressBtnList({ offset, limit, deviceType, storeId, control, serial, vat = 0 }) {
    if (!control) {
      control = 0
    }
    // 李峰说storeId废弃
    // return request.get(`${url}/api/v1/iot/frier-press-btn/list?offset=${offset}&limit=${limit}&device_type=${deviceType}&store_id=${storeId}&control=${control}`)
    return request.get(`${url}/api/v1/iot/frier-press-btn/list?offset=${offset}&limit=${limit}&device_type=${deviceType}&control=${control}&vat=${vat}&serial=${serial}`)
  },
  // 9.11.4.炸锅按键修改
  firePressBtnUpdate(data) {
    return request.put(`${url}/api/v1/iot/frier-press-btn/update`, data)
  },
  // 9.11.5.炸锅按键删除
  firePressBtnDelet(btnId) {
    return request.delete(`${url}/api/v1/iot/frier-press-btn/delete/${btnId}`)
  },
  // 9.11.6.炸锅按键删除产品
  firePressBtnCategoryDelete(prodId) {
    return request.delete(`${url}/api/v1/iot/frier-press-btn/delete/product/${prodId}`)
  },

  // 9.11.7.炸锅程序新增
  frierProgramAdd(data) {
    return request.post(`${url}/api/v1/iot/frier-program/add`, data)
  },

  // 9.11.8.炸锅程序新增
  frierProgramUpdate(data) {
    return request.put(`${url}/api/v1/iot/frier-program/update`, data)
  },

  // 9.11.9.炸锅程序列表
  frierProgramList({
    offset,
    limit = limit,
    ...data
  }) {
    return request.post(`${url}/api/v1/iot/frier-program/list?offset=${offset}&limit=${limit}`, data)
  },

  // 9.11.10.炸锅程序详情
  frierProgramDetail(data) {
    return request.post(`${url}/api/v1/iot/frier-program/detail`, data)
  },

  // 9.11.11.炸锅程序品相列表
  frierProgramEpqcList(data) {
    return request.post(`${url}/api/v1/iot/frier-program-epqc-category/list`, data)
  },

  // 9.11.12.炸锅程序列表
  frierProgramEpqcUpdate(data) {
    return request.put(`${url}/api/v1/iot/frier-program-epqc-category/update`, data)
  },

  // 9.11.13.炸锅程序品相列表组 (programs 和 9.11.11不一样)
  frierProgramsEpqcList(data) {
    return request.post(`${url}/api/v1/iot/frier-programs-epqc-category/list`, data)
  },
  // 9.11.14.炸锅按键品相配置
  frierPressBtnUpdate(data) {
    return request.put(`${url}/api/v1/iot/frier-press-btn/program-data/update`, data)
  },

  // 9.11.15.炸锅程序删除产品
  frierProgramsDelete(program_id) {
    return request.delete(`${url}/api/v1/iot/frier-program/delete/${program_id}`)
  },


  // 9.11.19.导入炸锅程序品相
  frierProgramEpqcCategoryImport(program_id) {
    return `${url}/api/v1/iot/frier-program-epqc-category/import?program_id=${program_id}`
  },



  // 9.11.21.炸锅3M值列表
  fryer3MList(queryData) {
    return request({
      method: 'get',
      url: `${url}/api/v1/iot/frier-3m-value/list`,
      params: queryData
    })
  },
  // 9.11.22.炸锅3M值更新
  fryer3MUpdate(paramsData) {
    return request.put(`${url}/api/v1/iot/frier-3m-value/update`, paramsData)
  },

  // 9.12.1.获取通用配置
  globalConfigList({ deviceType }) {
    return request.get(`${url}/api/v1/iot/global-conf?device_type=${deviceType}`)
  },
  // 9.12.2.设置通用配置
  globalConfigUpdate({ deviceType, data }) {
    return request.post(`${url}/api/v1/iot/global-conf/${deviceType}`, data)
  },

  // 9.16 OMD设备立即同步
  deviceSync({ storeId }) {
    return request.get(`${url}/api/v1/iot/sync/omd?store_id=${storeId}`)
  },

  // 9.16.2 规则同步
  ruleSync(queryData) {
    return request({
      url: `${url}/api/v1/iot/sync/rule`,
      method: 'get',
      params: queryData
    })
  },

  // 9.19.2 咖啡机按键产品列表
  btnProductList({ offset, limit = limit, paramsData }) {
    return request.post(`${url}/api/v1/iot/coffee_product/list?offset=${offset}&limit=${limit}`, paramsData)
  },
  // 9.19.3 咖啡机按键产品更新
  btnProductUpdate(paramsData) {
    return request.post(`${url}/api/v1/iot/coffee_product/update`, paramsData)
  },

  // 9.11.17.导入炸锅程序
  frierProgramImport({
    device_type,
    brand_name,
    model
  }) {
    return `${url}/api/v1/iot/frier-program/import?device_type=${device_type}&brand_name=${brand_name}&model=${model}`
  },


  // 9.20.1 餐厅可选判断
  storeCanSelectJudge(paramsData) {
    return request.post(`${url}/api/v1/iot/store/optional`, paramsData)
  },

  // 9.21.1 按餐厅展示滤水系统配置
  filterWaterList(storeId) {
    return request.get(`${url}/api/v1/iot/waterfilter/config/list?store_id=${storeId}`)
  },
  // 9.21.2 更新滤水系统配置更换时间
  filterWaterConfigUpdate(paramsData) {
    return request.put(`${url}/api/v1/iot/waterfilter/config/update`, paramsData)
  }
}
